package dS.ProjectGPS.LeicaOWI;

import javax.microedition.lcdui.*;

public class FormOwiRPP extends Form implements FormOwi {

  OWIAgent owiAgent = null;

  ChoiceGroup remoteport = new ChoiceGroup("Port", ChoiceGroup.EXCLUSIVE);

  public FormOwiRPP(OWIAgent o) {
    super("Remote Primary Port");

    owiAgent = o;

    try {
      ndsInit();
    }
    catch (Exception ex) {
    }
  }

  public void ndsInit() throws Exception {
    append(remoteport);
    remoteport.append("Port 1", null);
    remoteport.append("Port 2", null);
    remoteport.append("Port 3", null);
    remoteport.append("Terminal Port", null);
  }

  public void update() {
    // N/A
  }

  public void save() {

    String msgId = "RPP";

    // Setup SET parameters
    String[] outputs = {
                       msgId, "" + (remoteport.getSelectedIndex() + 1),
    };

    //Send message and update form if successful
    int ackCode = (owiAgent.set(msgId, OWI.setMessage(outputs)));
    Controller.showACKAlert(this, this, ackCode);

  }

}
